﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Reflection;

namespace Kokomo
{
	public static class EnumExtensions
	{
		public static string GetDescription(this Enum value)
		{
			Type enumType = value.GetType();
			string valueName = Enum.GetName(enumType, value);
			FieldInfo field = enumType.GetField(valueName);
			DescriptionAttribute descriptionAttribute = field.GetCustomAttribute<DescriptionAttribute>();
			string description = (descriptionAttribute == null) ? null : descriptionAttribute.Description;
			return description;
		}
	}
}
